2
2
.
.
4
4
.
.
8
8
R
R
e
e
t
t
u
u
r
r
n
n
-
-
V
V
i
i
e
e
w
w
-
-
H
H
T
T
M
M
L
L
I
I
n
n
f
f
o
o
[
[
G
G
]
]
In this tutorial we will build simple Spring Boot Application that only has Controller that returns static HTML page.
Application Schema [Results]
Spring Boot Starters
GROUP
DEPENDENCY
DESCRIPTION
Web
Spring Web
Enables @Controller, @RequestMapping and Tomcat Server.
Template Engines
Thyemeleaf
Enables Controller to return reference to HTML file test.html
P
P
r
r
o
o
c
c
e
e
d
d
u
u
r
r
e
e
Create Project: controller_application (add Spring Boot Starters from the table)
Create Package: controllers (inside package com.ivoronline.test_spring_boot)
– Create Class: MyController.java (inside package controllers)
Create HTML File: test.html (inside directory resources/templates)
MyController.java
package com.ivoronline.controller_application.controllers;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
@Controller
public class MyController {
@RequestMapping("/Hello")
public String hello() {
System.out.println("Hello from Controller");
return "test";
}
}
test.html
<title>Test.html</title>
Hello from test.html
test.html
http://localhost:8080/Hello
Tomcat
MyController
R
R
e
e
s
s
u
u
l
l
t
t
s
s
http://localhost:8080/Hello
Console
Hello from Controller
Application Structure
pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>